//
//  XNMoreDataTableViewCell.m
//  XINNingOA
//
//  Created by samuel on 2021/7/15.
//

#import "XNMoreDataTableViewCell.h"

@interface XNMoreDataTableViewCell()


@property (nonatomic, weak) UILabel *lab;

@end

@implementation XNMoreDataTableViewCell

+ (instancetype)tabelViewCellWithTableView:(UITableView *)tableView
                                  ForIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"XNMoreDataTableViewCellID";
    XNMoreDataTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        cell = [[XNMoreDataTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setSubView];
    }
    return self;
}

- (void)setSubView
{
    self.contentView.backgroundColor = [UIColor colorWithHexString:@"#F8F8F8"];
    UIView *container = [[UIView alloc] init];
    container.backgroundColor = [UIColor whiteColor];
    container.layer.cornerRadius = 10;
    container.clipsToBounds = YES;
    [self.contentView addSubview:container];
    [container mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(20);
        make.right.equalTo(self.contentView).offset(-20);
        make.top.equalTo(self.contentView).offset(8);
        make.bottom.equalTo(self.contentView).offset(-8);
    }];
    
    UILabel *lab = [[UILabel alloc] init];
    lab.textColor = [UIColor colorWithHexString:@"#358AFF"];
    lab.font = [UIFont systemFontOfSize:14];
    [container addSubview:lab];
    self.lab = lab;
    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(container).offset(20);
        make.right.equalTo(container).offset(-10);
        make.height.mas_equalTo(16);
        make.top.equalTo(container).offset(8);
        make.bottom.equalTo(container).offset(-8);
    }];
    
    UIImageView *arrow = [[UIImageView alloc] init];
    arrow.image = [UIImage imageNamed:@"arrow"];
    [self.contentView addSubview:arrow];
    [arrow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(container);
        make.right.equalTo(container).offset(-20);
        make.size.mas_equalTo(CGSizeMake(14, 14));
    }];

}

- (void)setTitle:(NSString *)title
{
    _title = title;
    self.lab.text = title;
}


@end
